
const __runPythonLibFile = (pythonFile,extParamStr) => SHELL(`python3 ${ path.join(PYTHON_LIB,pythonFile) } ${extParamStr.join(" ")}`)

const __convertParam = params => params.map(p => {


	if(isInteger(p)){
		return "int="+p;
	}

	if(isString(p)){
		if(p.indexOf("0x") === 0){
			return "hex="+convertToStdHex(p)
		}
		return "str="+p;
	}

	if(isArray(p)){
		return "hex="+convertToStdHex(SHA256_TREE(p))
	}

	throw "param sign error"

})

const PRIVATE_SIGNATURE = ({privateKey,params}) => {
	if(!privateKey)
		throw `please input the privateKey :${params}`
	return __runPythonLibFile("sign.py",__convertParam([privateKey,...params]))
}

const AGGREGATE_SIGNATURE_LIST = signatureList => {
	return __runPythonLibFile("aggregateSignList.py",signatureList)
}


const STANDER_COIN_SIGNATURE = signData =>{
	const backStr = __runPythonLibFile("standarCoinSign.py",[JSON.stringify(JSON.stringify(signData))]);
	return JSON.parse(backStr);
}

const READ_MNEMONIC = mnemonicStr => {
	if(!mnemonicStr)
		throw 'param mnemonic must be exist!'
	const backStr = __runPythonLibFile("readMnemonic.py",[mnemonicStr]);

	const data = JSON.parse(backStr);

	data.$address=XCH_ADDRESS_PREFIX+data.$address;

	return data;
}






